<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                template="/layout/main.xhtml">
    <ui:define name="title">Create Post</ui:define>
    <ui:define name="content">

        <h:form>
            <h2>New Post</h2>

            <h:panelGroup rendered="#{loginBean.user ne null}">
                <h:panelGrid columns="2">
                    <h:outputLabel value="Title"/>
                    <h:inputText value="#{createPostBean.title}" required="true"/>
                    <h:outputLabel value="Date"/>
                    <h:outputText value="#{createPostBean.date}"/>
                </h:panelGrid>
                <h:inputTextarea value="#{createPostBean.content}" required="true"/>
                <h:commandButton value="Save" actionListener="#{createPostBean.savePost}"/>
            </h:panelGroup>

            <h:panelGroup rendered="#{loginBean.user eq null}">
                You need to be
                <h:link value="logged in" outcome="login">
                    <f:param name="resume" id="r" value="post-create"/>
                </h:link>
                to create a new post.
            </h:panelGroup>
        </h:form>
    </ui:define>
</ui:composition>
